#!/usr/bin/env bash

    ##############
    # install.sh #
    ##############

# This program installs the Faridayix operating system

# This program is part of Rutherford, an artificial intelligence for the
# Faridayix computer operating system.

# Copyright (C) 2009 Scott C. MacCallum
# scottmaccal@gmail.com
# http://code.google.com/p/faridayix/source/browse/trunk/rutherford/shell/install.sh

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

install()
{
 local developer

 clear

 printf "Hello, $USER.
  espeak -s 75 "Hello, $USER."

# Format hard drive 'a'
# Format disk [device hard drive 'a']

fdisk /dev/hda

# Create a primary partition for hard drive 'a'.
# Create a primary swap partition for hard drive 'a'.
# Need to script an easy way to do this.

# Make an Linux third extended file system for partition one on hard drive 'a'.
# Be verbose about the process.
# Make to file system [verbose] [journal] 
# [slash device slash hard drive 'a' partition one].

mke2fs -v -j /dev/hda1

# Make a Linux swap file system for partition two on hard drive 'a'.
# Make swap [slash device slash hard drive 'a' partition two].

mkswap /dev/hda2

# Enable the newly created swap space. Be verbose about the process.
# Swapon [verbose] [slash device slash hard drive 'a' partition two]

swapon --verbose /dev/hda2

# Make a directory for the developmental version of Faridayix. Be verbose about
# the process. Create the parent directories if needed.
# Make directory [verbose] [parents] [slash mount slash faridayix-0-20081102]

mkdir --verbose --parents /mnt/faridayix-0-20091102

# Set an environment variable FARIDAYIX to the developmental version of the
# Faridayix directory.
# Export global system variable FARIDAYIX equals slash mount slash
# faridayix-0-20091102.

export FARIDAYIX=/mnt/faridayix-0-20081102

# Mount hard drive 'a' partition one, type Linux extended three, to the
# developemental copy of the faridayix directory. Be verbose about the
# process.
# Mount [type] ext3 [verbose] [slash device slash hard drive 'a' partition one]
# [$FARIDAYIX]

mount --verbose --type ext3 /dev/hda1 $FARIDAYIX

# Make a directory called 'source' in the mount, faridayix-0-20081102 directory.
# Be verbose about it the process.
# Make directory [verbose] [dollar sign FARIDAYIX slash source]

mkdir --verbose $FARIDAYIX/source

# Set the permissions for everyone on the slash mount slash
# faridayix-0-20081102 slash source directory to read, write, and
# execute. Make the directory sticky so that a file can only be deleted
# by its creator. Be verbose about the process.
# Change mode [verbose] [all plus write set sticky bit]

chmod --verbose a+wt

 printf "I will now determine the fastest site to download from."
  espeak -s 75 "I will now determine the fastest site to download from."

# Insert code here.

 printf "I will now download the GNU's Not UNIX Compiler Collection's core archived and compressed program source code."
  espeak -s 75 "I will now download the GNU's Not UNIX Compiler Collection's core archived and compressed program source code."
   wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.4.2/gcc-core-4.4.2.tar.bz2

 printf "I will now check the signature of the GNU's Not UNIX Compiler Collection's core archived and compressed program source code.
  espeak -s 75 "I will now check the signature of the GNU's Not UNIX Compiler Collection's core archived and compressed program source code."
   
 printf "I will now compile the GNU's Not UNIX Compiler Collection's core program source code."
  espeak -s 75 "I will now compile the GNU's Not UNIX Compiler Collection's core program source code."

 printf "I will now download the Burrows-Wheeler Transform Zip program source code."
  espeak -s 75 "I will now download the Burrows-Wheeler transform Zip program source code."
   wget http://bzip.org/1.0.5/bzip2-1.0.5.tar.gz

 printf "I will now download the GNU's Not UNIX Zip program source code."
  espeak -s 75 "I will now download the GNU's Not UNIX Zip program code."
   wget ftp://ftp.gnu.org/gnu/gzip/gzip-1.3.13.tar.gz

 printf "I will now download the GNU's Not UNIX Tape Archive program source code."
  espeak -s 75 "I will now download the GNU's Not Unix Tape Archive program source code."
   wget ftp://ftp.gnu.org/gnu/tar/tar-1.22.tar.gz

 printf "I will now download the Subversion program."

 wget http://subversion.tigris.org/downloads/subversion-1.6.6.tar.bz2

 sudo apt-get install --assume-yes subversion
  printf "Hello $USER, are you a core developer of the Faridayix operating system? "
   read developer

 if [ "$developer" == "yes" ]; then
  printf "\nWhat is your name on this computer system? "
   espeak -s 75 "What is your name on this computer system? " 
    read name
     sudo svn checkout https://faridayix.googlecode.com/svn/trunk/ /usr/local/share/faridayix --username $name
      sudo chmod --recursive +x /usr/local/share/faridayix
       sudo apt-get install --assume-yes libreadline5
        sudo pushd /usr/local/share/faridayix
         sudo wget http://www.newlisp.org/downloads/newlisp_10.1.6-utf8_i386.deb
          sudo dpkg -i newlisp_10.1.6-utf8_i386.deb
           sudo rm --force newlisp_10.1.6-utf8_i386.deb
            sudo popd
             sudo apt-get purge --assume-yes bluez-alsa
              sudo cp /usr/local/share/faridayix/faridayix /usr/bin
               printf "Would you like to run the faridayix program now? "
                faridayix
#END OF FILE